
# 根据 ID 进行搜索的工具

import arxiv
import pickle
from .utils import mkdir_if_not_exist

def SearchId(id:str):
    r = next(arxiv.Client().results(arxiv.Search(id_list=[str(id)])))
    entry_id_url = str(r.entry_id)
    entry_id = entry_id_url.split("/")[-1]
    file_path = f"data/{entry_id}.pkl"
    mkdir_if_not_exist("data/")
    with open(file_path,"wb") as fp:
        pickle.dump(r,fp)

    print(f"dump {entry_id} ok")
    return entry_id
